<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>今天吃什么？</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .container {
            background-color: white;
            padding: 2rem;
            border-radius: 20px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            text-align: center;
            max-width: 90%;
            width: 400px;
        }

        h1 {
            color: #2c3e50;
            margin-bottom: 2rem;
            font-size: 2rem;
        }

        .food-display {
            background-color: #f8f9fa;
            padding: 1.5rem;
            border-radius: 10px;
            margin: 1.5rem 0;
            min-height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #foodResult {
            font-size: 1.5rem;
            color: #34495e;
            font-weight: bold;
        }

        #startButton {
            background-color: #3498db;
            color: white;
            border: none;
            padding: 1rem 2rem;
            border-radius: 50px;
            font-size: 1.2rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        #startButton:hover {
            background-color: #2980b9;
            transform: translateY(-2px);
        }

        #startButton:active {
            transform: translateY(0);
        }

        .animate {
            animation: bounce 0.5s ease;
        }

        @keyframes bounce {
            0% { transform: scale(1); }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>今天吃什么？</h1>
        <div class="food-display">
            <p id="foodResult">点击按钮开始选择</p>
        </div>
        <button id="startButton">开始选择</button>
    </div>

    <script>
        // 食物列表
        const foods = [
            '麻辣烫', '火锅', '炒饭', '面条', '汉堡',
            '披萨', '寿司', '盖浇饭', '煲仔饭', '沙拉',
            '炸鸡', '烤肉', '饺子', '粥', '便当',
            '三明治', '炒面', '烤鱼', '麻辣香锅', '小龙虾'
        ];

        // 获取DOM元素
        const startButton = document.getElementById('startButton');
        const foodResult = document.getElementById('foodResult');

        // 是否正在选择中
        let isSelecting = false;
        let selectionInterval;

        // 随机选择食物的函数
        function getRandomFood() {
            return foods[Math.floor(Math.random() * foods.length)];
        }

        // 开始选择动画
        function startSelection() {
            if (isSelecting) return;
            
            isSelecting = true;
            startButton.textContent = '停止选择';
            
            // 快速切换显示不同的食物
            selectionInterval = setInterval(() => {
                foodResult.textContent = getRandomFood();
            }, 50);
        }

        // 停止选择动画
        function stopSelection() {
            isSelecting = false;
            startButton.textContent = '开始选择';
            clearInterval(selectionInterval);
            
            // 选择最终结果
            const finalFood = getRandomFood();
            foodResult.textContent = finalFood;
            
            // 添加动画效果
            foodResult.classList.add('animate');
            setTimeout(() => {
                foodResult.classList.remove('animate');
            }, 500);
        }

        // 点击按钮事件处理
        startButton.addEventListener('click', () => {
            if (!isSelecting) {
                startSelection();
                // 设置3秒后自动停止
                setTimeout(stopSelection, 3000);
            }
        });
    </script>
</body>
</html> 